package com.streetsmart.test;
/**
 * Test activity to lookup places nearby a geo point in a certain radius
 */
import java.util.Vector;

import org.json.JSONException;

import com.streetsmart.MyBusiness;
import com.streetsmart.MyLocation;
import com.streetsmart.R;
import com.streetsmart.Utilities;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class DirectoryLookupActivity extends Activity {
	
	@Override
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.lookup);		
	}
	
	public void lookup(View v) throws JSONException{
		EditText address = (EditText) findViewById(R.id.editTextAddress);
		EditText disp = (EditText) findViewById(R.id.editTextBusinesses);
		double[] geocode;
		geocode = Utilities.getLatAndLng(address.getText().toString());
		MyLocation loc = new MyLocation(geocode[0], geocode[1], address.toString());
		float radius = 5000;
		Vector<String> types = new Vector<String>();
		types.add("restaurant");
		Vector<MyBusiness> Buslist = Utilities.peekNearByBusinesses(loc, radius, types);
		int count = Buslist.size();
		disp.setText("List of Businesses nearby to the address above\n");
		for(int i = 0; i < count; i++){
			disp.append(Buslist.get(i).getName());
			disp.append("\n");
		}		
	}
	
}
